<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <script src="../static/jquery-3.3.1.min.js"></script>
</head>
<body>

<h1>登录--认证中心</h1>
用户名：<input id="account" type="text">
密码：<input id="password" type="password">
<button id="login">登录</button>

<script>
    $("#login").click(function () {

        var account = $("#account").val();
        var password = $("#password").val();

        $.ajax({
            url: "/login",
            data: {account:account,password:password},
            type: "POST",
            dataType: "json",
            success: function (data) {
                var code = data['code'];
                if(code === 'USER100016'){
                    // 密码错误
                    alert("用户名或密码错误！");
                    return;
                }
                var sourceUrl = data['data'];
                console.log("===>success, sourceUrl is " + sourceUrl);
                window.location.href= sourceUrl;
            },
            error: function (data) {
                console.log(data);
                console.log("===>error");
            }
        })
    })
</script>
</body>
</html>